<html>
<head><meta charset="utf-8"><title>Standalone mir-opt tool · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html">Standalone mir-opt tool</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203874880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203874880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luqman Aden <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203874880">(Jul 14 2020 at 19:16)</a>:</h4>
<p>Curious if there were any eventual plans for a standalone mir-opt tool (akin to Swift's sil-opt or LLVM's opt) to take in MIR and output the result after optimizations. Would definitely help while writing/testing mir opts without having to rely on rustc generating the right mir you want to test.</p>



<a name="203875538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203875538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203875538">(Jul 14 2020 at 19:22)</a>:</h4>
<p><a href="https://github.com/rust-lang/miri/issues/196">https://github.com/rust-lang/miri/issues/196</a></p>



<a name="203875700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203875700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203875700">(Jul 14 2020 at 19:24)</a>:</h4>
<p>It is not as easy as for LLVM or Swift, as MIR itself just describes function bodies. It doesn't describe any types and other necessary things to actually do something useful with it.</p>



<a name="203875816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203875816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203875816">(Jul 14 2020 at 19:25)</a>:</h4>
<p>LLVM-IR at least describes the full input of the optimizations. Rust's MIR doesn't.</p>



<a name="203875950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203875950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luqman Aden <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203875950">(Jul 14 2020 at 19:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Standalone.20mir-opt.20tool/near/203875538">said</a>:</p>
<blockquote>
<p><a href="https://github.com/rust-lang/miri/issues/196">https://github.com/rust-lang/miri/issues/196</a></p>
</blockquote>
<p>Ah, there's the issue I could've sworn I saw a while back <span aria-label="smile" class="emoji emoji-263a" role="img" title="smile">:smile:</span></p>



<a name="203876209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203876209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luqman Aden <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203876209">(Jul 14 2020 at 19:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Standalone.20mir-opt.20tool/near/203875700">said</a>:</p>
<blockquote>
<p>It is not as easy as for LLVM or Swift, as MIR itself just describes function bodies. It doesn't describe any types and other necessary things to actually do something useful with it.</p>
</blockquote>
<p>yea, i guess it'd need some sort of augmented mir</p>



<a name="203894938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203894938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203894938">(Jul 14 2020 at 22:14)</a>:</h4>
<p>you would need something like Rust but with macros expanded, and function bodies replaced with MIR</p>



<a name="203894988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203894988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203894988">(Jul 14 2020 at 22:15)</a>:</h4>
<p>in fact we could try to make something like this work for testing</p>



<a name="203896166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203896166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203896166">(Jul 14 2020 at 22:29)</a>:</h4>
<p>^ ditto</p>



<a name="203896185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203896185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203896185">(Jul 14 2020 at 22:29)</a>:</h4>
<p>I would love to see this available for testing MIR</p>



<a name="203896307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203896307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203896307">(Jul 14 2020 at 22:30)</a>:</h4>
<p>I mean not MIR, but transformations over MIR</p>



<a name="203924111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203924111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203924111">(Jul 15 2020 at 07:34)</a>:</h4>
<p>it would also tremendously help exploring MIR semantics with miri</p>



<a name="203924139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203924139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203924139">(Jul 15 2020 at 07:34)</a>:</h4>
<p>right now there's MIR we just cannot generate so we cannot actually test how miri behaves on them and whether that's what we want</p>



<a name="203926965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203926965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203926965">(Jul 15 2020 at 08:12)</a>:</h4>
<p>Maybe we could add an forever unstable <code>mir</code> item kind to the parser, ast, hir and translate that directly to MIR bodies?</p>



<a name="203927220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927220">(Jul 15 2020 at 08:16)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I would just have a way to toggle what the body is supposed to be</p>



<a name="203927241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927241">(Jul 15 2020 at 08:16)</a>:</h4>
<p>ideally we can avoid parsing anything special and just have a transformation to lower AST to MIR</p>



<a name="203927260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927260">(Jul 15 2020 at 08:16)</a>:</h4>
<p>that AST -&gt; HIR would invoke</p>



<a name="203927320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927320">(Jul 15 2020 at 08:17)</a>:</h4>
<p>creating types is a bit of a problem, since <code>TyCtxt</code> doesn't exist yet, hmpf</p>



<a name="203927387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927387">(Jul 15 2020 at 08:18)</a>:</h4>
<p>maybe we can just do AST -&gt; HIR and avoid using anything that woul desugar</p>



<a name="203927405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927405">(Jul 15 2020 at 08:18)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> so basically it would look like a bunch of function calls</p>



<a name="203927413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927413">(Jul 15 2020 at 08:18)</a>:</h4>
<p>mostly,</p>



<a name="203927429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927429">(Jul 15 2020 at 08:18)</a>:</h4>
<p>I forogt where I wrote down my last thoughts on this</p>



<a name="203927454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927454">(Jul 15 2020 at 08:19)</a>:</h4>
<p>right, but I want to write normal code and mir in the same file ^^</p>



<a name="203927482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927482">(Jul 15 2020 at 08:19)</a>:</h4>
<p>but yeah parsing -&gt; AST -&gt; HIR without any changes to the AST or HIR would be great because you can defer reinterpeting it as MIR until after you have a <code>TyCtxt</code></p>



<a name="203927491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927491">(Jul 15 2020 at 08:19)</a>:</h4>
<p>and we'll want to write basic blocks with arbitrary schemes, so we can't just use rust code</p>



<a name="203927493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927493">(Jul 15 2020 at 08:19)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> that's the point, you have like a <code>#[mir]</code> or something annotation</p>



<a name="203927501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927501">(Jul 15 2020 at 08:19)</a>:</h4>
<p>even <code>loop</code> is not ok?</p>



<a name="203927530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927530">(Jul 15 2020 at 08:19)</a>:</h4>
<p>you'd be using a subset of the Rust syntax as a way to represent MIR</p>



<a name="203927579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927579">(Jul 15 2020 at 08:20)</a>:</h4>
<p>to avoid wriitng a MIR parser etc.</p>



<a name="203927599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927599">(Jul 15 2020 at 08:20)</a>:</h4>
<p>if you want to do all that extra work, be my guest, but I don't think it's entirely worth it</p>



<a name="203927634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927634">(Jul 15 2020 at 08:20)</a>:</h4>
<p>oh, so you want <code>SetDiscriminant(place, val)</code> to be a function?</p>



<a name="203927649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927649">(Jul 15 2020 at 08:21)</a>:</h4>
<p>not a real one, just using the syntax</p>



<a name="203927655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927655">(Jul 15 2020 at 08:21)</a>:</h4>
<p>yea</p>



<a name="203927663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927663">(Jul 15 2020 at 08:21)</a>:</h4>
<p>basically an intrinsic ^^</p>



<a name="203927693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927693">(Jul 15 2020 at 08:21)</a>:</h4>
<p>hopefully the syntax we pick will be weird enough so that it wouldn't actually compile without the <code>#[mir]</code> or w/e...</p>



<a name="203927832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927832">(Jul 15 2020 at 08:23)</a>:</h4>
<p>as a first step we can create a bunch of intrinsics that cover all the mir statement kinds and only work with <code>-Zunstable-features</code></p>



<a name="203927897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203927897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203927897">(Jul 15 2020 at 08:24)</a>:</h4>
<p>that seems like the MVP which is the easiest to implement and gives us fun things like inserting <code>StorageDead</code> in random places</p>



<a name="203928235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203928235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203928235">(Jul 15 2020 at 08:28)</a>:</h4>
<p>you went in the direction I <em>really</em> wanted to avoid, but I <em>suppose</em> it wouldn't be impossible to have that available for testing</p>



<a name="203928283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203928283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203928283">(Jul 15 2020 at 08:29)</a>:</h4>
<p>I'm worried about putting anything mentioning those intrinsics in <code>core</code>/<code>std</code>, maybe we need to start having a <code>rustc_test</code> crate with random goodies tests can easily access?</p>



<a name="203928442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203928442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203928442">(Jul 15 2020 at 08:31)</a>:</h4>
<p>anyway that feels orthogonal to being able to inject custom MIR bodies (which would likely require a special "HIR-&gt;MIR direct lowering" pass that bypasses typeck and regular MIR building)</p>



<a name="203928450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203928450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203928450">(Jul 15 2020 at 08:31)</a>:</h4>
<p>we don't need to put these intrinsics in <code>core</code>/<code>std</code></p>



<a name="203928459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203928459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203928459">(Jul 15 2020 at 08:31)</a>:</h4>
<p>we can just add a new crate for mir debugging</p>



<a name="203928522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Standalone%20mir-opt%20tool/near/203928522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Standalone.20mir-opt.20tool.html#203928522">(Jul 15 2020 at 08:32)</a>:</h4>
<p><code>rustc_test</code> or <code>rustc_mir_test</code> if we don't want to use one crate for everything, seems like it could work fine</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>